export const setstorage=(key,value)=>{
  try{
    wx.setStorageSync(key, value)
  }catch(error){
    console.error(`存储指定${key}数据发生了异常`)
  }
}
export const getstorage=(key)=>{
  try{
    return wx.getStorageSync(key)
  }catch(error){
    console.error(`读取指定${key}数据发生了异常`)
  }
}
export const removestorage=(key)=>{
  try{
    wx.removeStorageSync(key)
  }catch(error){
    console.error(`删除指定${key}数据发生了异常`)
  }
}
export const clearstorage=()=>{
  try{
    wx.clearStorageSync()
  }catch(error){
    console.error(`同步删除所有数据发生了异常`)
  }
}
// 异步
export const asyncsetstorage=(key,data)=>{
  return new Promise((resolve)=>{
    wx.setStorage({
      key,
      data,
      complete(res){
        resolve(res)
      }
    })
  })
}
export const asyncgetstorage=(key)=>{
  return new Promise((resolve)=>{
    wx.getStorage({
      key,
      complete(res){
        resolve(res)
      }
    })
  })
}
export const asyncremovestorage=(key)=>{
  return new Promise((resolve)=>{
    wx.removeStorage({
      key,
      complete(res){
        resolve(res)
      }
    })
  })
}
export const asyncclearstorage=()=>{
  return new Promise((resolve)=>{
    wx.clearStorage({
      complete(res){
        resolve(res)
      }
    })
  })
}
